package com.itzmn.examinations.gaosi;

import java.util.Scanner;
import java.util.Stack;

/**
 * @Author: 张梦楠
 * @Date: 2018/11/10 20:04
 * 简书：https://www.jianshu.com/u/d611be10d1a6
 * 码云：https://gitee.com/zhangqiye
 * @Description:
 *   高思笔试第一题：
 *    一个字符串有() [] {}组成，判断其中的括弧是否是对称的
 */
public class Num2 {


    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String[] split = s.split("");

        boolean b = false;
        Stack<String> strings = new Stack<String>();
        for (int i=0;i<split.length;i++){
            String s1 = split[i];
            if (s1.equals("(")||s1.equals("{")||s1.equals("[")){
                strings.push(split[i]);
            }else {

                b=true;
                if (s1.equals("}")){
                    if (strings.isEmpty()){
                        System.out.println("No");
                        break;
                    }
                    String pop = strings.pop();
                    if (!pop.equals("{")){
                        System.out.println("No");
                        break;
                    }
                }
                if (s1.equals(")")){
                    if (strings.isEmpty()){
                        System.out.println("No");
                        break;
                    }
                    String pop = strings.pop();
                    if (!pop.equals("(")){
                        System.out.println("No");
                        break;
                    }
                }
                if (s1.equals("]")){
                    if (strings.isEmpty()){
                        System.out.println("No");
                        break;
                    }
                    String pop = strings.pop();
                    if (!pop.equals("[")){
                        System.out.println("No");
                        break;
                    }
                }

                if (i == split.length-1){
                    System.out.println("Yes");
                }
            }


        }
        if (!b){
            System.out.println("No");
        }

    }
}
